import{IsIn, IsNotEmpty,IsNumber,IsString, Max, Min}from "class-validator";
import {Column, Entity, PrimaryGeneratedColumn} from "typeorm";

@Entity()//用来标记类为TypeORM实体和列
export class Student{
    @PrimaryGeneratedColumn()//自定义自增主键列，对应数据库中的自增ID字段
    id:number;

    @Column()
    @IsNotEmpty({message:"姓名不能为空"})
    @IsString({message:"姓名必须是字符串"})
    name:string;

    @Column()
    @IsNotEmpty({message:"年龄不能为空"})
    @IsNumber({},{message:"姓名必须是数字"})
    @Min(1,{message:'年龄不能小于1岁'})
    @Max(99,{message:'年龄不能大于99岁'})
    age:number;

    @Column()
     @IsNotEmpty({message:"性别不能为空"})
    @IsString({message:"性别必须是字符串"})
    @IsIn(['男','女'],{message:'性别只能是男或女'})
    gender:string;

    @Column()
    @IsNotEmpty({message:"专业不能为空"})
    @IsString({message:"专业必须是字符串"})
    major:string;
   
}



